home *** CD-ROM | disk | FTP | other *** search
/ System Booster / System Booster.iso / Screenblankers / GBlanker / GSource / Blankers / Interference / blank.c next >
C/C++ Source or Header  |  1996-09-26  |  2KB  |  95 lines

  1. /*
  2.  *  Copyright (c) 1994 Michael D. Bayne.
  3.  *  All rights reserved.
  4.  *
  5.  *  Please see the documentation accompanying the distribution for distribution
  6.  *  and disclaimer information.
  7.  */
  8.  
  9. #include <exec/memory.h>
  10. #include "/includes.h"
  11.  
  12. LONG ExtendPal;
  13. Triplet *ColorTable = 0L;
  14.  
  15. VOID Defaults( PrefObject *Prefs )
  16. {
  17.     Prefs[0].po_Level = 2;
  18.     Prefs[2].po_ModeID = getTopScreenMode();
  19.     Prefs[2].po_Depth = 4;
  20. }
  21.  
  22. LONG Interference( struct Screen *Scr )
  23. {
  24.     LONG Wid = Scr->Width, Hei = Scr->Height, RetVal = OK, Pixel = 0, x, y;
  25.     LONG factor, Colors = ( 1L << Scr->BitMap.Depth ) - 1;
  26.     LONG Transition =  Colors * 2 - 1, PixelVal;
  27.     struct RastPort *R = &( Scr->RastPort );
  28.  
  29.     ScreenToFront( Scr );
  30.  
  31.     factor = RangeRand( 20 ) + 1;
  32.     for( y = -Hei / 2 + 1; y <= 0 && RetVal == OK; y++ )
  33.     {
  34.         for( x = -Wid / 2 + 1; x <= 0; x++ )
  35.         {
  36.             PixelVal =  (( x * x + y * y ) / factor ) % Transition;
  37.             if( PixelVal >= Colors )
  38.                 PixelVal = Transition - PixelVal;
  39.             
  40.             SetAPen( R, PixelVal + 1 );
  41.             WritePixel( R, Wid / 2 - 1 + x, Hei / 2 - 1 + y );
  42.             WritePixel( R, Wid / 2 - 1 - x, Hei / 2 - 1 + y );
  43.             WritePixel( R, Wid / 2 - 1 + x, Hei / 2 - 1 - y );
  44.             WritePixel( R, Wid / 2 - 1 - x, Hei / 2 - 1 - y );
  45.             if(!( ++Pixel % 600 ))
  46.                 RetVal = ContinueBlanking();
  47.         }
  48.         RainbowPalette( Scr, ColorTable, 1L, ExtendPal );
  49.         WaitTOF();
  50.     }
  51.  
  52.     for( x = 0; x < 400 && RetVal == OK; x++ )
  53.     {
  54.         WaitTOF();
  55.         if(!( x % 4 ))
  56.         {
  57.             RainbowPalette( Scr, ColorTable, 1L, ExtendPal );
  58.             RetVal = ContinueBlanking();
  59.         }
  60.     }
  61.  
  62.     return RetVal;
  63. }
  64.  
  65. LONG Blank( PrefObject *Prefs )
  66. {
  67.     struct Screen *Scr;
  68.     struct Window *Wnd;
  69.     LONG RetVal = OK;
  70.     
  71.     Scr = OpenScreenTags( 0L, SA_Depth, Prefs[2].po_Depth, SA_Quiet, TRUE,
  72.                          SA_Overscan, OSCAN_STANDARD, SA_Behind, TRUE,
  73.                          SA_DisplayID, Prefs[2].po_ModeID, TAG_DONE );
  74.     if( Scr )
  75.     {
  76.         SetRast(&( Scr->RastPort ), 0 );
  77.         ColorTable = RainbowPalette( Scr, 0L, 1L,
  78.                                     ExtendPal = Prefs[0].po_Level );
  79.         Wnd = BlankMousePointer( Scr );
  80.  
  81.         ScreenToFront( Scr );
  82.  
  83.         while( RetVal == OK )
  84.             RetVal = Interference( Scr );
  85.  
  86.         UnblankMousePointer( Wnd );
  87.         RainbowPalette( NULL, ColorTable, 1L, ExtendPal );
  88.         CloseScreen( Scr );
  89.     }
  90.     else
  91.         RetVal = FAILED;
  92.  
  93.     return RetVal;
  94. }
  95.